package com.kingdee.eas.custom.hr.compensation.app;

import org.apache.log4j.Logger;
import javax.ejb.*;
import java.rmi.RemoteException;
import com.kingdee.bos.*;
import com.kingdee.bos.util.BOSObjectType;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.metadata.rule.RuleExecutor;
import com.kingdee.bos.metadata.MetaDataPK;
//import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.framework.ejb.AbstractEntityControllerBean;
import com.kingdee.bos.framework.ejb.AbstractBizControllerBean;
//import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.service.ServiceContext;
import com.kingdee.bos.service.IServiceContext;

import java.lang.String;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.eas.basedata.org.AdminOrgFacadeFactory;
import com.kingdee.eas.basedata.org.AdminOrgUnitFactory;
import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
import com.kingdee.eas.basedata.org.JobFactory;
import com.kingdee.eas.basedata.org.JobInfo;
import com.kingdee.eas.basedata.org.PositionCollection;
import com.kingdee.eas.basedata.org.PositionFactory;
import com.kingdee.eas.basedata.org.PositionInfo;
import com.kingdee.eas.basedata.org.PositionMemberFactory;
import com.kingdee.eas.basedata.org.PositionMemberInfo;
import com.kingdee.eas.basedata.person.PersonFactory;
import com.kingdee.eas.basedata.person.PersonInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.eas.framework.CoreBaseCollection;
import com.kingdee.eas.hr.base.CodingRuleManageFacadeFactory;
import com.kingdee.eas.hr.base.HRBillBaseCollection;
import com.kingdee.eas.hr.base.HRBillBaseEntryInfo;
import com.kingdee.eas.hr.base.IHRBillBaseEntry;
import com.kingdee.eas.hr.base.app.HRBillAppUtils;
import com.kingdee.eas.hr.base.app.HRBillBaseControllerBean;
import com.kingdee.eas.hr.base.app.IHRBillBizBean;
import com.kingdee.eas.hr.canon.cbase.AdminOrgBaseInfo;
import com.kingdee.eas.hr.canon.cbase.GradeInfo;
import com.kingdee.eas.hr.emp.IPersonWorkExpCur;
import com.kingdee.eas.hr.emp.PersonWorkExpCurFactory;
import com.kingdee.eas.hr.emp.PersonWorkExpCurInfo;
import com.kingdee.eas.hr.org.JobLevelFactory;
import com.kingdee.eas.hr.org.JobLevelInfo;
import com.kingdee.eas.framework.CoreBillBaseCollection;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.ObjectBaseCollection;
import com.kingdee.eas.custom.hr.base.AttendanceCodeInfo;
import com.kingdee.eas.custom.hr.base.DirectAndIndirectInfo;
import com.kingdee.eas.custom.hr.compensation.PaidleaveBuyCollection;
import com.kingdee.eas.custom.hr.compensation.PaidleaveBuyEntryFactory;
import com.kingdee.eas.custom.hr.compensation.PaidleaveBuyEntryInfo;
import com.kingdee.eas.custom.hr.compensation.PaidleaveBuyInfo;

public class PaidleaveBuyControllerBean extends AbstractPaidleaveBuyControllerBean
{
    private static Logger logger =
        Logger.getLogger("com.kingdee.eas.custom.hr.compensation.app.PaidleaveBuyControllerBean");
    
	@Override
	protected String getBillField() throws BOSException, EASBizException {
		return "parent";
	}

	@Override
	protected IHRBillBizBean getBizBean() throws BOSException, EASBizException {
		return new PaidleaveBuyBizBean();
	}

	@Override
	protected String getEntryEffectDateField() throws BOSException,
			EASBizException {
		//return "effectDate";
		return null;
	}

	@Override
	protected String getEntryField() throws BOSException, EASBizException {
		return "entrys";
	}

	@Override
	protected IHRBillBaseEntry getEntryInterface(Context ctx)
			throws BOSException, EASBizException {
		return PaidleaveBuyEntryFactory.getLocalInstance(ctx);
	}

	@Override
	protected void _entryEffect(Context ctx, HRBillBaseEntryInfo entry)
			throws BOSException, EASBizException {
		//super._entryEffect(ctx, entry);
	}
	
	@Override
	protected void _addnew(Context ctx, IObjectPK pk, IObjectValue model)
			throws BOSException, EASBizException {
		this.setNumberFromCodingRule(ctx, model);
		super._addnew(ctx, pk, model);
	}

	@Override
	protected IObjectPK _addnew(Context ctx, IObjectValue model)
			throws BOSException, EASBizException {
		this.setNumberFromCodingRule(ctx, model);
		return super._addnew(ctx, model);
	}

	private void setNumberFromCodingRule(Context ctx, IObjectValue model)
			throws EASBizException, BOSException {
		String number = CodingRuleManageFacadeFactory.getLocalInstance(ctx)
				.getNumberFromCodingRule(model, null, null);
		if (number == null)
			return;
		((PaidleaveBuyInfo) model).setNumber(number);
	}
	
}